let a;
let arr = $(".lunbo1")[0];
console.log(arr);
let arr2 = $(".dowebok")[0];
let arr3 = $("h2")[0];

let flag = false
let userArr = JSON.parse(localStorage.getItem('power_data'))
console.log(userArr);
// let arr4 = $("#admin")[0];
$(function () {
  $.ajax({
    url: "./../login.json",
    dataType: "json",
    success: function (thisCenter) {
      //将获取到的数据转为字符串存储到本地
      let myUserList = JSON.stringify(thisCenter)

      //存储到本地localStoraged
      localStorage.setItem("myUser", myUserList)
      // initUser(thisCenter)
    }
  })
})


function getlocal(name) {
  return JSON.parse(localStorage.getItem(name))
}

function jump() {
  // console.log('登录');
  //找到用户名输入框的值，并存入某个变量中
  let arr4 = $("#admin")[0].value;
  let arr5 = $("#name")[0].value;
  let arr6 = $("#password")[0].value;

  // 申明变量获取本地的数据
  // let a = (getlocal("myUser").users);
  for (i = 0; i < userArr.length; i++) {
    if (arr4 == userArr[i].id && arr5 == userArr[i].user && arr6 == userArr[i].pwd) {
      flag = true
      localStorage.setItem('userInfo', JSON.stringify(userArr[i]))
      window.location.href = "../../html/cao_xiao_xu/Public.html";
      // console.log(a[i].admin);
      break;
    }
  }
  if (!flag) {
    alert('账号密码有误，请重新输入')
  }

}





//循环用户数组，比对哪个用户和输入框的值相等，再跳转到首页


// window.location.href = "./../index.html"










var signUpButton = document.getElementById('signUp')
var signInButton = document.getElementById('signIn')
var container = document.getElementById('dowebok')


signUpButton.addEventListener('click', function () {
  container.classList.add('right-panel-active')
})

signInButton.addEventListener('click', function () {
  container.classList.remove('right-panel-active')
})

function xixi() {
  arr3.style.marginTop = 200 + "px";
  arr2.style.marginTop = 680 + "px";
}
xixi()

function haha() {

  if (arr.style.marginLeft == "") {
    arr.style.marginLeft = "0%";
  }
  arr.style.marginLeft = (parseInt(arr.style.marginLeft) - 100) + "%"
  if ((parseInt(arr.style.marginLeft)) < -400) {
    arr.style.marginLeft = "0%"
  }
}
window.onload = function () {
  a = setInterval(haha, 3000)
}